# -*- coding:utf-8 -*-

import json
from bs4 import BeautifulSoup
import requests

'''
获取中国地质大学（武汉）所有院系名称
'''
name_link = []
college_name = []          #该字段仅用于存放中国地质大学（武汉）所有学院名称

def college_info(page):          #地大的学院名称是从地大本科招生信息网中获取，因此分为3页，每一页分别获取学院名
	#获取院系信息页面
	url = 'http://zhaosheng.cug.edu.cn/news/34/' + str(page) + '.html'
	r = requests.get(url)
	return r.content

def parse_college_name():
	for page in range(1,4):
		html = college_info(page)
		soup = BeautifulSoup(html)
		name_link = soup.find_all('h2')
		for link in name_link:
			college_name_list = link.find('a').get_text().strip()
			college_name.append(college_name_list)
			print json.dumps(college_name_list,indent=4,ensure_ascii=False)
	return college_name

if __name__ == '__main__':
	parse_college_name()
